package org.activequant.util.log;

import java.util.ArrayList;
import java.util.List;

import org.activequant.core.domainmodel.account.Order;
import org.activequant.core.domainmodel.data.Quote;
import org.activequant.core.domainmodel.events.OrderEvent;

/**
 * This is a facade to forward or dispatch a log request to multiple
 * sub loggers. For example, instantiate it with an instance of a 
 * PnlLogger and a CSVLogger and inject this facade into the 
 * PaperBroker in order to get pnl values logged on the fly. <br>
 * MultiLoggerFacade implements IAQLogger.<br/>
 * Holds the following associated variable:
 * <ul>
 * <li>theLoggers(List&lt;IAQLogger&gt;)</li>
 * </ul>
 * History: <br>
 * - [05.10.2009] Created (Ulrich Staudinger)<br>
 * <br>
 * 
 * @author Ulrich Staudinger
 *
 */
public class MultiLoggerFacade implements IAQLogger {
	/**
	 * constructs a MultiLoggerFacade(implements IAQLogger) using the given aLoggers(IAQLogger...) to fill its associated theLoggers(List&lt;IAQLogger&gt;)
	 * @param aLoggers
	 */
	public MultiLoggerFacade(IAQLogger ... aLoggers)
	{
		for(IAQLogger myLogger : aLoggers)
			theLoggers.add(myLogger);
	}
	/**
	 * iterates the associated theLoggers(List&lt;IAQLogger&gt;) and logs the given anOrder(Order) and anEvent(OrderEvent) into each of them
	 */
	public void log(Order anOrder, OrderEvent anEvent) {
		for(IAQLogger myLogger : theLoggers)
			myLogger.log(anOrder, anEvent);
	}
	/**
	 * iterates the associated theLoggers(List&lt;IAQLogger&gt;) and logs the given aQuote(Quote) into each of them
	 */
	public void log(Quote aQuote) {
		for(IAQLogger myLogger : theLoggers)
			myLogger.log(aQuote);
	}
	/**
	 * private List&lt;IAQLogger&gt; theLoggers = new ArrayList&lt;IAQLogger&gt;();
	 */
	private List<IAQLogger> theLoggers = new ArrayList<IAQLogger>();

}
